def calculator():
    while True:
        try:
            op = input("请输入一个四则运算算式（例如1+2）：")
            if "+" in op:
                a = op.split("+")
                if len(a) > 2:
                    raise Exception("本计算机只支持简单四则运算")
                result = int(a[0]) + int(a[1])
                print(result)
            elif "-" in op:
                a = op.split("-")
                if len(a) > 2:
                    raise Exception("本计算机只支持简单四则运算")
                result = int(a[0]) - int(a[1])
                print(result)
            elif "*" in op:
                a = op.split("*")
                if len(a) > 2:
                    raise Exception("本计算机只支持简单四则运算")
                result = int(a[0]) * int(a[1])
                print(result)
            elif "/" in op:
                a = op.split("/")
                if len(a) > 2:
                    raise Exception("本计算机只支持简单四则运算")
                result = int(a[0]) / int(a[1])
                print(result)
            elif op == "exit":
                print("感谢使用本计算器！")
                break
            else:
                raise Exception("本计算机只支持简单四则运算")
        except ZeroDivisionError:
            print("除数不能为0")
        except ValueError:
            print("本计算机只支持简单四则运算")
        except Exception as e:
            print(e, type(e))
